package com.tandashi.springbootstudy01.study;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.Month;

public class LocalDateTest {
    public static void main(String[] args) {

        LocalDate now = LocalDate.now();
        System.out.println("当前日期："+now);

        LocalDate of = LocalDate.of(2023, 05, 01);
        System.out.println(of);

        LocalDate of3 = LocalDate.of(2023, 05, 01);
        System.out.println("5.1日期比较："+of3.isAfter(of));

        LocalDate of4 = LocalDate.of(2023, 05, 02);
        System.out.println("5.1与5.1of相等："+of.isEqual(of3));
        System.out.println("5.2与5.1比较："+of4.isAfter(of));

        //日期判断
        int i = now.compareTo(of);
        System.out.println("日期判断小于："+i);
        int i1 = of.compareTo(of);
        System.out.println("日期判断等于："+i1);
        int i2 = of.compareTo(now);
        System.out.println("日期判断大于："+i2);

        boolean before = now.isBefore(of);
        System.out.println("现在是5.1之前："+before);

        boolean after = of.isAfter(now);
        System.out.println("5.1是现在之后："+after);

        boolean equal = now.isEqual(now);
        System.out.println("相等："+equal);

        LocalDateTime of1 = LocalDateTime.of(2023, 05, 01, 0, 0, 0);
        System.out.println("5.1带时分秒"+of1);

        LocalDateTime now1 = LocalDateTime.now();
        System.out.println("现在带时分秒："+now1);

        LocalDateTime of2 = LocalDateTime.of(2023, 5, 1, 0, 0, 1);
        System.out.println("5.1 1秒："+of2);
        boolean after1 = of2.isAfter(of1);
        System.out.println("5.1带时分秒比较："+after1);

        System.out.println("现在带时分秒小于5.1："+now1.isBefore(of1));

        LocalDateTime dateOf51 = LocalDateTime.of(2023, Month.MAY, 1, 0, 0);
        System.out.println("51日期："+dateOf51);

        LocalDateTime da51 = LocalDateTime.of(2023, 05, 1, 0, 0,0);
        System.out.println("51日期："+da51);

        LocalDateTime of5 = LocalDateTime.of(2023, 04, 24, 15, 19);
        LocalDateTime now2 = LocalDateTime.now();
        System.out.println(of5);
        System.out.println(now2);
        System.out.println("当前时间大于4.24 0时："+now2.isAfter(of5));


    }
}
